<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="directive.jsp" />
<jsp:include page="header.jsp" />
<div id="inner_wrap">
<div id="inner_hold">
<div class="wrap_in" style="padding: 15px 1px;">

<c:choose>
<c:when test="${!empty param.placeOrder}">
    <jsp:setProperty name="order" property="cart" value="${cart}"/>
    <jsp:setProperty name="order" property="shipping" value="${shipping}"/>
    <jsp:setProperty name="order" property="username" value="${user.username}"/>
        
    <c:choose>
        <c:when test="${order.createOrder == true}">
            <h1>Your order has been submitted successfully!</h1>
            <h2>Thank you for shopping with AAL!</h2>
            <jsp:setProperty name="cart" property="itemsReset" value="${true}"/>
        </c:when>
        <c:otherwise>
            <h1>Error while trying to connect to database!</h1>
            <h2>Please <a href="contact.jsp">contact us</a> for support!</h2>
        </c:otherwise>
    </c:choose>
</c:when>
<c:otherwise>
    
	<div class="pad_30_both">
		<div class="rgtspn"><div id="secure_badge" title="Secure Online Shopping"></div></div>
		<h1>Payment Information</h1>
		<p class="font_small">Step <strong class="red">2</strong> of 2</p>
		<div class="empty"></div>
	</div>


	<form action="checkout.jsp" method="post" name="bagform" id="bagform">
	<div id="frm_bag_in">
		<table width="100%" cellspacing="0" cellpadding="0">
			<tr>
				<td id="frm_inputs" valign="top">
					<h3>Shipping Address</h3>
					<div class="mar_25_lft frm_sep">
						<p class="rgtspn"><a href="javascript:history.back()" class="blue">Edit</a></p>
						<p><strong>${shipping.receiverName}</strong></p>
						<p style="clear: both">${shipping.shippingAddress}</p>
						<p>Phone: ${shipping.receiverPhone}</p>
					</div>

					<h3>Billing Address</h3>
					<div class="mar_25_lft frm_sep">
						<p class="rgtspn"><a href="javascript:history.back()" class="blue">Edit</a></p>
						<p><strong>${shipping.customerName}</strong></p>
						<p style="clear: both">${shipping.billingAddress}</p>
					</div>


					<h3>Payment Method</h3>
					<div class="mar_25_lft">
						<p>We only support <strong><a href="contact.jsp">Wire transfer</a></strong> at the moment</p>
					</div>
				</td>
				<td width="50">&nbsp;</td>
				<td width="250" valign="top">
					<div id="dekont">
                        <p class="rgtspn">$<span id="tot_p"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.netAmount}"/></span></p>
                        <p style="padding-top: 2px">Subtotal</p>
                        <div class="empty" style="height: 10px"></div>

                        <p class="rgtspn">$<span id="bag_g_ship"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.shippingAmount}"/></span></p>
                        <p style="padding-top: 2px">Shipping</p>
                        <div class="empty" style="height: 10px"></div>

                        <p id="discount_tot" class="rgtspn">-$<span id="discount_tot"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.discountAmount}"/></span></p>
                        <p style="padding-top: 2px">Discount</p>
                        <div class="empty" style="height: 10px"></div>

                        <p class="rgtspn">$<span id="gift_tot"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.taxAmount}"/></span></p>
                        <p style="padding-top: 2px">Tax</p>
                        <div class="empty" style="height: 18px"></div>

                        <p class="rgtspn red" style="font-weight: bold">$<span id="bag_g_tot"><fmt:formatNumber type="number" maxFractionDigits="2" value="${cart.totalAmount}"/></span></p>
                        <p style="padding-top: 2px"><strong>Total</strong></p>
                        <div class="empty"></div>
                    </div>
					<div class="font_small_l brdr_thick">* All values, unless otherwise stated, are in <strong>US dollars</strong></div>
				</td>
			</tr>
		</table>
	</div>
	<div id="frm_bag">
		<input type="submit" name="placeOrder" id="submit" class="but_place_order" value="OK, Place My Order" />
	</div>
	</form>
</c:otherwise>
</c:choose>
</div>
</div>
</div>

<jsp:include page="footer.jsp" />